from django.db import models
from index.models import SpeciesModel
from user.models import UserModel


class VarietyModel(models.Model):
    variety = models.CharField(max_length=25, verbose_name="宠物品种", blank=False, null=False)
    species = models.ForeignKey(SpeciesModel, on_delete=models.CASCADE, verbose_name="物种id")

    def __str__(self):
        return self.variety

    class Meta:
        db_table = 'variety'


class PetModel(models.Model):
    name = models.CharField(max_length=25, verbose_name="宠物名", null=False)
    birthday = models.DateTimeField(verbose_name="出生日期", null=False)
    gender = models.IntegerField(choices=(('0', '雄性'), ('1', '雌性')), verbose_name="性别", null=False)
    sterilization = models.BooleanField(default=False, verbose_name="是否绝育", null=False)
    weight = models.FloatField(verbose_name="重量", null=False)
    home_day = models.DateTimeField(null=True, blank=True, verbose_name="到家日期")
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name="用户id")
    species = models.ForeignKey(SpeciesModel, on_delete=models.CASCADE, verbose_name="物种id")

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'pet'
